#ifndef ABSTRACTITEMPROXYMODEL_H
#define ABSTRACTITEMPROXYMODEL_H



#include "proxies_global.h"



#include <ItemModel.h>



#include <QAbstractProxyModel>
#include <QStringList>



typedef QPersistentModelIndex SourceIndex;
typedef QPersistentModelIndex ProxyIndex;

typedef QMap<SourceIndex, ProxyIndex> IndexMap;



class PROXIESSHARED_EXPORT AbstractItemProxyModel : public QAbstractProxyModel
{
    Q_OBJECT

public:

    AbstractItemProxyModel(QObject *parent = 0);

    virtual QModelIndex index(int row, int column, const QModelIndex &parent) const;
    virtual QModelIndex parent(const QModelIndex &child) const;

    virtual int rowCount(const QModelIndex &parent) const;

    virtual QVariant data(const QModelIndex &proxyIndex, int role) const;
    virtual bool setData(const QModelIndex &index, const QVariant &value, int role);

    virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
    virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const;

    virtual void setSourceModel(QAbstractItemModel *sourceModel);

    void addMapping(const SourceIndex& source, const ProxyIndex& proxy);

    ItemModel* itemModel() const;


protected slots:

    virtual void remap() = 0;
    virtual void clear();


protected:

    IndexMap m_indexes;


};



#endif // ABSTRACTITEMPROXYMODEL_H


